package jwf.util;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class Logger {

    private static Logger instance = null;

    private BufferedWriter writer;
    
    private Logger() {
	try {
	    writer = new BufferedWriter(new FileWriter(new File("log"), true));
	} catch (IOException e) {
	    e.printStackTrace();
	}
    }

    public static Logger getInstance() {
	if (instance == null) {
	    synchronized (Logger.class) {
		if (instance == null) {
		    instance = new Logger();
		}
	    }
	}
	return instance;
    }
    
    public void info(String message) {
	if (writer != null) {
	    try {
		writer.write(message + "\n");
		writer.flush();
	    } catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	    }
	}
    }
    
    public static void main(String[] args) {
	Logger.getInstance().info("abc");
    }
}
